<%@page import="java.util.ArrayList"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	pageContext.setAttribute("basePath",request.getContextPath());
%>
<!DOCTYPE html>
<html lang="zh">
<head>

<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="keywords" content="">
<meta name="description" content="">
<title>生产记录</title>
<link rel="shortcut icon" href="favicon.ico">
<link href="${basePath }/static/css/bootstrap.min.css" rel="stylesheet" />
<link href="${basePath }/static/css/font-awesome.min.css" rel="stylesheet" />
<!-- bootstrap-table 表格插件样式 -->
<link href="${basePath }/static/ajax/libs/bootstrap-table/bootstrap-table.min.css"
	rel="stylesheet" />
<link href="${basePath }/static/css/animate.css" rel="stylesheet" />
<link href="${basePath }/static/css/style.css" rel="stylesheet" />
<link href="${basePath }/static/ruoyi/css/ry-ui.css" rel="stylesheet" />


<link href="${basePath }/static/ajax/libs/jquery-layout/jquery.layout-latest.css"
	rel="stylesheet" />


<link
	href="${basePath }/static/ajax/libs/jquery-ztree/3.5/css/metro/zTreeStyle.css"
	rel="stylesheet" />

</head>
<body class="gray-bg">
<!--补全项目路径,JSP--> 
<%    pageContext.setAttribute("basePath",request.getContextPath()); %>

	<div class="ui-layout-center">
		<div class="container-div">
			<div class="row">
				<div class="col-sm-12 search-collapse">
					<form id="user-form">
						<input type="hidden" id="deptId" name="deptId"> <input
							type="hidden" id="parentId" name="parentId">
						<div class="select-list">
							<ul>

								<li class="select-time"><label>时间： </label> <input
									type="text" class="time-input" id="startTime"
									placeholder="开始时间" name="params[beginTime]" /> <span>-</span>
									<input type="text" class="time-input" id="endTime"
									placeholder="结束时间" name="params[endTime]" /></li>
								<li><a class="btn btn-primary btn-rounded btn-sm"
									onclick="$.table.search()"> <i class="fa fa-search"></i>&nbsp;搜索
								</a> <a class="btn btn-warning btn-rounded btn-sm"
									onclick="$.form.reset()"> <i class="fa fa-refresh"></i>&nbsp;重置
								</a></li>
							</ul>
						</div>
					</form>
				</div>


				<div class="col-sm-12 select-table table-striped">
					<div class="bootstrap-table">
						<div class="fixed-table-toolbar">
							<div class="bs-bars pull-left">
								<div class="btn-group-sm" id="toolbar" role="group">
									<a class="btn btn-success" onclick=""> <i
										class="fa fa-download"></i> 批量导出
									</a> <a class="btn btn-info" onclick=""> <i
										class="fa fa-upload"></i> 导入
									</a>
									<button class="btn btn-info btn-primary btn-xs"
										data-toggle="modal" data-target="#addRecord" type="button">
										<i class="glyphicon glyphicon-floppy-disk"></i>&nbsp;&nbsp;<span
											class="bold">添加记录</span>
									</button>
								</div>
							</div>
						</div>


						<div class="fixed-table-container" style="padding-bottom: 0px;">
							<div class="fixed-table-header" style="display: none;">
								<table></table>
							</div>
							<div class="fixed-table-body">
								<table id="bootstrap-table" data-mobile-responsive="true"
									class="table table-hover">
									<thead>
										<tr>
											<th class="bs-checkbox " style="width: 36px;" data-field="0"
												tabindex="0">
												<div class="th-inner ">
													<input name="btSelectAll" type="checkbox">
												</div>
												<div class="fht-cell"></div>
											</th>
											<th>
												<div class="th-inner ">#</div>
												<div class="fht-cell"></div>
											</th>
											<th>
												<div class="th-inner ">出库茶叶批次</div>
												<div class="fht-cell"></div>
											</th>
											<th>
												<div class="th-inner ">生产批次</div>
												<div class="fht-cell"></div>
											</th>
											<th>
												<div class="th-inner ">生产设备编号</div>
												<div class="fht-cell"></div>
											</th>
											<th>
												<div class="th-inner ">记录员</div>
												<div class="fht-cell"></div>
											</th>
											<th>
												<div class="th-inner ">记录时间</div>
												<div class="fht-cell"></div>
											</th>
											<th>
												<div class="th-inner ">生产状态</div>
												<div class="fht-cell"></div>
											</th>
											<th>
												<div class="th-inner ">操作</div>
												<div class="fht-cell"></div>
											</th>
										</tr>
									</thead>
									<tbody id="recordList">
										<c:forEach items="${query.list}" var="record"
											varStatus="status">
											<tr data-index="${status.count }">
												<td class="bs-checkbox "><input
													data-index="${status.count }" name="btSelectItem"
													type="checkbox"></td>
												<td>${status.count }</td>
												<td>${record.deliveryBatch }</td>
												<td>${record.productBatch }</td>
												<td>${record.deviceId }</td>
												<td>${record.producerId }</td>
												<td>${record.recordTime }</td>
												<td><span class="badge badge-primary">合格</span></td>
												<td>
													<button class="btn btn-info btn-primary btn-xs"
														data-toggle="modal" data-target="#detailModal"
														type="button" onclick="showDetail(this)">
														<i class="fa fa-key"></i>&nbsp;&nbsp;<span class="bold">详细</span>
													</button>
													<button class="btn btn-success btn-xs" type="button">
														<i class="fa fa-download"></i>&nbsp;&nbsp;<span
															class="bold">导出</span>
													</button>
												</td>
											</tr>
										</c:forEach>
									</tbody>
								</table>
							</div>
							<div class="fixed-table-footer" style="display: none;">
								<table>
									<tbody>
										<tr></tr>
									</tbody>
								</table>
							</div>

							<!-- 分页 -->
								<div class="fixed-table-pagination" style="display: block;">
								<div class="pull-left pagination-detail">
									<span class="pagination-info">第${query.pageNum }页，共${query.pages + 1}页，共
										${query.total } 条记录。</span>
								</div>
								<div class="pull-right pagination">
									<ul class="pagination pagination-outline">
										<c:choose>
											<c:when test="${query.pageNum == 1 }">
												<li class="page-pre active"><a
													href="javascript:void(0)">‹</a></li>
											</c:when>
											<c:otherwise>
												<li class="page-pre"><a
													href="${basePath }/production/record/getProductionRecord.do?pagenum=${query.pageNum - 1 }">‹</a>
												</li>
											</c:otherwise>
										</c:choose>

										<c:forEach items="${query.navigateNums }" var="num">
											<c:if test="${query.pageNum == num }">
												<li class="page-number active"><a
													href="javascript:void(0)">${num }</a></li>
											</c:if>
											<c:if test="${query.pageNum != num }">
												<li class="page-number"><a
													href="${basePath }/production/record/getProductionRecord.do?pagenum=${num }">${num }</a>
												</li>
											</c:if>
										</c:forEach>
										<c:if test="${query.pageNum == query.pages+1 }">
											<li class="page-next active"><a
												href="javascript:void(0)">›</a></li>
										</c:if>
										<c:if test="${query.pageNum < query.pages }">
											<li class="page-next"><a
												href="${basePath }/production/record/getProductionRecord.do?pagenum=${query.pageNum + 1 }">›</a>
											</li>
										</c:if>
									</ul>
								</div>
							</div>
						</div>
					</div>
					<div class="clearfix"></div>
				</div>
			</div>
		</div>
	</div>







	<!-- 添加记录模态框 -->

	<div class="modal inmodal fade" id="addRecord" tabindex="-1"
		role="dialog" aria-hidden="true" style="display: none;">
		<div class="modal-dialog modal-lg">
			<div class="modal-content">
				<div class="modal-header">
					<button type="button" class="close" data-dismiss="modal">
						<span aria-hidden="true">×</span><span class="sr-only">Close</span>
					</button>
					<h4 class="modal-title">添加生产记录</h4>
				</div>
				<small class="font-bold">
					<div class="modal-body" id="new-record">
						<select class="form-control m-b" name="account" id="recordHead">
							<option value="none">--请选择记录类型--</option>
							<option value="form-fixation-body">杀青记录</option>
							<option value="form-twist-body">揉捻记录</option>
							<option value="form-dry-body">干燥记录</option>
							<option value="form-package-body">打包记录</option>
						</select>

						<!-- 杀青记录表单 -->
						<form class="new-record-body form-fixation-body" hidden>
							<div class="form-group">
									<div class="input-group m-b">
										<span class="input-group-addon">生产批次</span> <input
											type="text" placeholder="生产批次" name="productBatch" class="form-control">
									</div>
									<div class="input-group m-b">
										<span class="input-group-addon">出库茶叶批次</span> <input type="text"
											placeholder="出库茶叶批次" name="deliveryBatch" class="form-control">
									</div>
									<div class="input-group m-b">
										<span class="input-group-addon">设备编号</span> <input type="text"
											placeholder="设备编号" name="deviceId" class="form-control">
									</div>
									<div class="input-group m-b">
										<span class="input-group-addon">生产员ID</span> <input type="text"
											placeholder="生产员ID" name="producerId" class="form-control">
									</div>
									<div class="input-group m-b">
										<span class="input-group-addon">鲜叶含水量</span> <input type="text"
											placeholder="鲜叶含水量" name="freshLeafWaterContent" class="form-control">
									</div>
									<div class="input-group m-b">
										<span class="input-group-addon">杀青后含水量</span> <input type="text"
											placeholder="杀青后含水量" name="weightLast" class="form-control">
									</div>
									
							</div>
							<div class="modal-footer">
								<button type="button" class="btn btn-white" data-dismiss="modal">取消</button>
								<button type="submit" class="btn btn-primary" onclick="FixationCheck()">保存</button>
							</div>
						</form>


						<!-- 揉捻记录表单 -->
						<form class="new-record-body form-twist-body" hidden>
							<div class="form-group">
								<div class="input-group m-b">
									<span class="input-group-addon">茶叶出库批次</span> <input
										type="text" placeholder="茶叶出库批次" name="deliveryBatch"
										class="form-control">
								</div>
								<div class="input-group m-b">
									<span class="input-group-addon">生产批次</span> <input type="text"
										placeholder="生产批次" name="productBatch" class="form-control">
								</div>
								<div class="input-group m-b">
									<span class="input-group-addon">设备编号</span> <input type="text"
										placeholder="设备编号" name="deviceId" class="form-control">
								</div>
								<div class="input-group m-b">
									<span class="input-group-addon">投叶量</span> <input type="text"
										placeholder="投叶量" name="volume" class="form-control">
								</div>
								<div class="input-group m-b">
									<span class="input-group-addon">含水量</span> <input type="text"
										placeholder="含水量" name="waterRate" class="form-control">
								</div>
								<div class="input-group m-b">
									<span class="input-group-addon">细胞破损率</span> <input type="text"
										placeholder="细胞破损率" name="outCellRate" class="form-control">
								</div>
								<div class="input-group m-b">
									<span class="input-group-addon">叶形</span> <input type="text"
										placeholder="叶形" name="outShape" class="form-control">
								</div>
								<div class="input-group m-b">
									<span class="input-group-addon">成条率</span> <input type="text"
										placeholder="成条率" name="outRate" class="form-control">
								</div>
								<div class="input-group m-b">
									<span class="input-group-addon">生产员id</span> <input type="text"
										placeholder="生产员id" name="producerId" class="form-control">
								</div>
								<!-- <div class="input-group m-b">
										<span class="input-group-addon">记录时间</span> <input type="text"
											placeholder="记录时间" name="recordTime" class="form-control">
									</div> -->
							</div>
							<div class="modal-footer">
								<button type="button" class="btn btn-white" data-dismiss="modal">取消</button>
								<button type="submit" class="btn btn-primary"
									onclick="TwistCheck()">保存</button>
							</div>
						</form>

						<!-- 干燥记录表单 -->
						<form class="new-record-body form-dry-body" hidden>
                            <div class="form-group">
                                <div class="input-group m-b">
                                    <span class="input-group-addon">茶叶出库批次</span> <input
                                        type="text" placeholder="茶叶出库批次" name="deliveryBatch" class="form-control">
                                </div>
                                <div class="input-group m-b">
                                    <span class="input-group-addon">生产批次</span> <input type="text"
                                                                                       placeholder="生产批次" name="productBatch" class="form-control">
                                </div>
                                <div class="input-group m-b">
                                    <span class="input-group-addon">设备编号</span> <input type="text"
                                                                                       placeholder="设备编号" name="deviceId" class="form-control">
                                </div>
                                <div class="input-group m-b">
                                    <span class="input-group-addon">出产量</span> <input type="text"
                                                                                      placeholder="出产量" name="weight" class="form-control">
                                </div>
                                <div class="input-group m-b">
                                    <span class="input-group-addon">含水量</span> <input type="text"
                                                                                      placeholder="含水量" name="waterLastRate" class="form-control">
                                </div>
                                <div class="input-group m-b">
                                    <span class="input-group-addon">生产员id</span> <input
                                        type="text" placeholder="生产员id" name="producerId" class="form-control">
                                </div>
                            </div>
                            <div class="modal-footer">
                                <button type="button" class="btn btn-white" data-dismiss="modal">取消</button>
                                <button type="submit" class="btn btn-primary" onclick="DryCheck()" data-dismiss='modal'>保存</button>
                            </div>
						</form>
						
						


						<!-- 打包记录表单 -->
						<form class="new-record-body form-package-body" hidden>
							<div class="form-group">
									<div class="input-group m-b">
										<span class="input-group-addon">生产批次</span> <input type="text"
											placeholder="生产批次" name="productBatch" class="form-control">
									</div>
									<div class="input-group m-b">
										<span class="input-group-addon">出库茶叶批次</span> <input type="text"
											placeholder="出库茶叶批次" name="deliveryBatch" class="form-control">
									</div>
									<div class="input-group m-b">
										<span class="input-group-addon">设备编号</span> <input type="text"
											placeholder="设备编号" name="deviceId" class="form-control">
									</div>
									<div class="input-group m-b">
										<span class="input-group-addon">生产员Id</span> <input
											type="text" placeholder="生产员Id" name="producerId" class="form-control">
									</div>
									<div class="input-group m-b">
										<span class="input-group-addon">单位茶叶重量</span> <input type="text"
											placeholder="单位茶叶重量" name="teaWeight" class="form-control">
									</div>
									<div class="input-group m-b">
										<span class="input-group-addon">茶叶数量</span> <input type="text"
											placeholder="茶叶数量" name="teaNumber" class="form-control">
									</div>
									
							</div>
							<div class="modal-footer">
								<button type="button" class="btn btn-white" data-dismiss="modal">取消</button>
								<button type="submit" class="btn btn-primary" onclick="PackCheck()">保存</button>
							</div>
						</form>
						

					</div>
				</small>
			</div>
			<small class="font-bold"> </small>
		</div>
		<small class="font-bold"> </small>
	</div>


	<!-- 详情模态框 -->
	<div class="modal inmodal fade" id="detailModal" tabindex="-1"
		role="dialog" aria-hidden="true" style="display: none;">
		<div class="modal-dialog modal-lg">
			<div class="modal-content" id="recordDetail">
			</div>
			<small class="font-bold"> </small>
		</div>
	</div>

<script src="${basePath }/static/js/jquery.min.js"></script>
	<script src="${basePath }/static/js/bootstrap.min.js"></script>
	<!-- bootstrap-table 表格插件 -->
	<script
		src="${basePath }/static/ajax/libs/bootstrap-table/bootstrap-table.min.js"></script>
	<script
		src="${basePath }/static/ajax/libs/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
	<script
		src="${basePath }/static/ajax/libs/bootstrap-table/extensions/mobile/bootstrap-table-mobile.js"></script>
	<script
		src="${basePath }/static/ajax/libs/bootstrap-table/extensions/toolbar/bootstrap-table-toolbar.min.js"></script>
	<script
		src="${basePath }/static/ajax/libs/bootstrap-table/extensions/columns/bootstrap-table-fixed-columns.js"></script>
	<!-- jquery-validate 表单验证插件 -->
	<script src="${basePath }/static/ajax/libs/validate/jquery.validate.min.js"></script>
	<script src="${basePath }/static/ajax/libs/validate/messages_zh.min.js"></script>
	<script src="${basePath }/static/ajax/libs/validate/jquery.validate.extend.js"></script>
	<!-- jquery-validate 表单树插件 -->
	<script
		src="${basePath }/static/ajax/libs/bootstrap-treetable/bootstrap-treetable.js"></script>
	<!-- jquery-export 表格导出插件 -->
	<script
		src="${basePath }/static/ajax/libs/bootstrap-table/extensions/export/bootstrap-table-export.js"></script>
	<script
		src="${basePath }/static/ajax/libs/bootstrap-table/extensions/export/tableExport.js"></script>
	<!-- 遮罩层 -->
	<script src="${basePath }/static/ajax/libs/blockUI/jquery.blockUI.js"></script>
	<script src="${basePath }/static/ajax/libs/iCheck/icheck.min.js"></script>
	<script src="${basePath }/static/ajax/libs/layer/layer.min.js"></script>
	<script src="${basePath }/static/ajax/libs/layui/layui.js"></script>
	<script src="${basePath }/static/ruoyi/js/common.js?v=4.0.0"></script>
	<script src="${basePath }/static/ruoyi/js/ry-ui.js?v=4.0.0"></script>
	<script>
		var ctx = "\/";
	</script>
	<script src="${basePath }/static/ajax/libs/jquery-layout/jquery.layout-latest.js"></script>
	<script
		src="${basePath }/static/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.all-3.5.js"></script>
	<script>
		$("#recordHead").change(function(){
			// 显示前先将之前显示的表单隐藏，避免出现多个表单
			$("div#new-record .new-record-body").prop("hidden",true);
			var option = $("#recordHead").val();
			var element = "form." + option;
			booltag = $(element).prop("hidden",false);
		});
	</script>

	<script>
	//获取项目根目录
	function getRootPath() {
		let href = window.document.location.href;
		let pathName = window.document.location.pathname;
		let index = href.indexOf(pathName);
		let localhost = href.substring(0, index);
		let project = pathName.substring(0, (pathName.substr(1)
				.indexOf('/')) + 1);

		return (localhost + project);
	}

	var rootPath = getRootPath();
	
	
	/*杀青记录表单验证*/
		function FixationCheck() {
				$("form.form-fixation-body").validate({
		            rules: {
		            	productBatch: {
		                    required: true,
		                },
		            	deliveryBatch: {
		                    required: true,
		                },
		                deviceId: {
		                    required: true,
		                },
		                producerId:{
		                	required: true,
		                	number: true     //输入必须是数字
		                },
		                freshLeafWaterContent: {
		                    required: true,
		                    number: true,     //输入必须是数字
		                    max: 1,
		                    min: 0.01,        //输入的数字最小值为0.01，不能为0或者负数
		                },
		                weightLast : {
		                    required: true,
		                    number: true,     //输入必须是数字
		                    max: 1,			  //最大值为1
		                    min: 0.01,        //输入的数字最小值为0.01，不能为0或者负数
		                },
		            },
			
		submitHandler: function() {
		                //此处写请求后台的ajax
		                let data = $("form.form-fixation-body").serialize();
		                console.log(data);
		                $.ajax({
		                	url: rootPath + "/production/record/addFixationRecord.do",
		                	type:"POST",
		                	data : data,
		                	dataType : "json",
		                    success : function (response) {
		                    	if(response.Result=="success"){
		                    		layer.alert(response.message, {icon: 1, title:'提示'});
		                    	}else{
		                    		layer.alert(response.message, {icon: 2, title:'提示'});
		                    	}
		                    }                	  
		                });
		                
		            }
		        })
	        
	    }
	
		/*获取杀青记录*/
		function getFixationRecord() {
			$.ajax({
				url : rootPath
						+ "/production/record/getFixationRecord.do",
				type : "POST",
				success : function(response) {
					if(response.RESUTL === "failed"){
	                	$.modal.alert(response.message);
	                } else{
	                	var response = eval("("+response+")");
	                	$.modal.alert(response.message);
	             	record = response.record;
	                	
	                	var listinner = "<tr data-index='0'><td class='bs-checkbox '><input data-index='1' name='btSelectItem' type='checkbox'></td>"
	                    	+"<td>0</td>"
	                    	+"<td>"+ record.deliveryBatch +"</td>"
	                    	+"<td>"+ record.deviceId +"</td>"
	                    	+"<td>"+ record.producerId +"</td>"
	                    	+"<td>"+ record.recordTime +"</td>"
	                    	+"<td><span class='badge badge-primary'>合格</span></td><td><button class='btn btn-info btn-primary btn-xs'data-toggle='modal' data-target='#detailModal' type='button'>"
	    					+"<i class='fa fa-key'></i>&nbsp;&nbsp;<span class='bold'>详细</span></button>"
	    					+"<button class='btn btn-success btn-xs' type='button'><i class='fa fa-download'></i>&nbsp;&nbsp;<span class='bold'>导出</span>"
	    					+"</button></td></tr>";
	                    	$("#recordList").html(listinner);
	
	                } 
					
				}
			});
		}
		
		/*揉捻记录表单验证*/
		function TwistCheck() {
				$("form.form-twist-body").validate({
		            rules: {
		            	deliveryBatch: {
		                    required: true,
		                },
		                productBatch: {
		                    required: true,
		                },
		                deviceId: {
		                    required: true,
		                },
		                volume : {
		                    required: true,
		                    number: true,     //输入必须是数字
		                    min: 1,        //输入的数字最小值为0.01，不能为0或者负数
		                },
		                waterRate : {
		                    required: true,
		                    number: true,     //输入必须是数字
		                    max: 1,			  //最大值为1
		                    min: 0.01,        //输入的数字最小值为0.01，不能为0或者负数
		                },
		                outCellRate : {
		                    required: true,
		                    number: true,     //输入必须是数字
		                    max: 1,			  //最大值为1
		                    min: 0.01,        //输入的数字最小值为0.01，不能为0或者负数
		                },
		                outShape : {
		                    required: true
		                    
		                },
		                outRate:{
		                	required: true,
		                	number: true,     //输入必须是数字
		                    max: 1,			  //最大值为1
		                    min: 0.01,        //输入的数字最小值为0.01，不能为0或者负数
		                },
		                producerId:{
		                	required: true,
		                	number: true     //输入必须是数字
		                }
	/* 	                recordTiem:{
		                	required: true
		                } */
		                
		            },
		          //错误提示信息
		            messages: {
		            	volume: {
		                    number: "请输入正确数字",
		                    max: "输入最大值为1",
		                    min: "输入最小值为0.01"
		                },
		                waterRate: {
		                    number: "请输入正确数字",
		                    max: "输入最大值为1",
		                    min: "输入最小值为0.01"
		                },
		                outCellRate: {
		                    number: "请输入正确数字",
		                    max: "输入最大值为1",
		                    min: "输入最小值为0.01"
		                },
		                outRate: {
		                    number: "请输入正确数字",
		                    max: "输入最大值为1",
		                    min: "输入最小值为0.01"
		                },
		                producerId: {
		                    number: "请正确输入员工id"
		                }
		                
		            },
		            submitHandler: function() {
		                //此处写请求后台的ajax
		                let data = $("form.form-twist-body").serialize();
		                $.ajax({
		                	url: rootPath + "/production/record/addTwistRecord.do",
		                	type:"POST",
		                	data : data,
		                	dataType : "json",
		                    success : function (response) {
		                    	if(response.Result=="success"){
		                    		layer.alert(response.message, {icon: 1, title:'提示'});
		                    	}else{
		                    		layer.alert(response.message, {icon: 2, title:'提示'});
		                    	}
		                    }                	  
		                });
		                
		            }
		        })
	        
	    }

		

		/*获取干燥生产记录*/
	function getDryRecord() {
        $.ajax({
            url : rootPath + "/getDryRecord.do",
            type : "POST",
            success : function(response) {
                var response = eval("("+response+")");
                record = response.record;
                var listinner = "";
                for(let i = 0 ; i < record.length ; i++ ) {
                    listinner = listinner +
                        "<tr data-index='0'><td class='bs-checkbox '><input data-index='1' name='btSelectItem' type='checkbox'></td>"
                        + "<td>" + (i+1) + "</td>"
                        + "<td>" + record[i].deliveryBatch + "</td>"
                        + "<td>" + record[i].productBatch + "</td>"
                        + "<td>" + record[i].deviceId + "</td>"
                        + "<td>" + record[i].producerId + "</td>"
                        + "<td>" + record[i].recordTime + "</td>"
                        + "<td><span class='badge badge-primary'>合格</span></td>"
                        +"<td><button class='btn btn-info btn-primary btn-xs'data-toggle='modal' onclick='showDryDetail(this,"+record[i].id+")' data-target='#detailModal' type='button'>"
                        + "<i class='fa fa-key'></i>&nbsp;&nbsp;<span class='bold'>详细</span></button>"
                        + "<button class='btn btn-success btn-xs' type='button'><i class='fa fa-download'></i>&nbsp;&nbsp;<span class='bold'>导出</span>"
                        + "</button></td></tr>";
                    }
                $("#recordList").html(listinner);
            }
        });
    }
	 /*干燥记录表单验证*/
    function DryCheck() {
        $("form.form-dry-body").validate({
            rules: {
                deliveryBatch: {
                    required: true,
                },
                productBatch: {
                    required: true,
                },
                deviceId: {
                    required: true,
                },
                weight : {
                    required: true,
                    number: true,     //输入必须是数字
                },
                waterLastRate : {
                    required: true,
                    number: true,     //输入必须是数字
                    max: 1,			  //最大值为1
                    min: 0.01,        //输入的数字最小值为0.01，不能为0或者负数
                },
                producerId:{
                    required: true,
                },
                recordTime:{
                    required: true,
				}

            },
            //错误提示信息
            messages: {
                waterLastRate: {
                    number: "请输入正确数字",
                    max: "输入最大值为1",
                    min: "输入最小值为0.01"
                },
                weight: {
                    number: "请输入正确数字",
                },
                producerId: {
                    number: "请正确输入员工id"
                }
            },
            submitHandler: function() {
                //此处写请求后台的ajax


            }
        })
        let data = $("form.form-dry-body").serialize();
        $.ajax({
            url: rootPath + "/production/addDryRecord.do",
            type:"POST",
            data : data,
            dataType : "json",
            success : function (response) {
            	if(response.Result=="success"){
            		layer.alert(response.message, {icon: 1, title:'提示'});
            	}else{
            		layer.alert(response.message, {icon: 2, title:'提示'});
            	}
            }
        });
    }

/*干燥生产记录修改*/
    function updateDryRecordStandardCheck(){

        $("form.form-updateDryRecored-body").validate({
            rules: {
                deliveryBatch: {
                    required: true,
                },
                productBatch: {
                    required: true,
                },
                deviceId: {
                    required: true,
                },
                weight : {
                    required: true,
                    number: true,     //输入必须是数字
                },
                waterLastRate : {
                    required: true,
                    number: true,     //输入必须是数字
                    max: 1,			  //最大值为1
                    min: 0,        //输入的数字最小值为0.01，不能为0或者负数
                },
                producerId:{
                    required: true,
                },
                recordTime:{
                    required: true,
					date: true,
                }

            },
            messages: {
                waterLastRate: {
                    number: "请输入正确数字",
                    max: "输入最大值为1",
                    min: "输入最小值为0.01"
                },
                weight: {
                    number: "请输入正确数字",
                },
                producerId: {
                    number: "请正确输入员工id"
                },
                recordTime:{
					date : "请按照日期格式输入"
				}
            },
        });
        let data = $("form.form-updateDryRecored-body").serialize();
        $.ajax({
            url : rootPath + "/updateDryRecord.do",
            type : "POST",
            data : data,
            dataType : "json",
            success : function (response) {
                alert(response.message);
            },
        });


    }
	/*打包记录列表*/
		function getPackRecord() {
		$.ajax({
			url : rootPath + "/getPackRecord.do",
			type : "POST",
			dataType:"json",
			success : function(response) {
				if(response.RESUTL === "failed"){
                	$.modal.alert(response.message);
                }else{
                	var PackRecordList=response.PackRecordList;
                	for(let i=0;i<PackRecordList.length;i++){ 		
                		var list=
                			'<tr data-index="0">'
                				+'<td class="bs-checkbox "><input data-index="0" name="btSelectItem" type="checkbox"></td>'
                				+'<td>'+PackRecordList[i].id+'</td>'
                				+'<td>'+PackRecordList[i].operateBatch+'</td>'
                				+'<td>'+PackRecordList[i].deliveryBatch+'</td>'
                				+'<td>'+PackRecordList[i].deviceId+'</td>'
                				+'<td>'+PackRecordList[i].producerId+'</td>'
                				+'<td>打包</td>'
                				+'<td>'+PackRecordList[i].packTime+'</td>'
                				+'<td><span class="badge badge-primary">合格</span></td>'
                				+'<td>'
                				+'<button class="btn btn-info btn-primary btn-xs"'
                					+'data-toggle="modal" data-target="#packModal" type="button"  onclick="showDetail(this)">'
                					+'<i class="fa fa-key"></i>&nbsp;&nbsp;<span class="bold">详细</span>'
                				+'</button>'
                				+'&nbsp;&nbsp;<button class="btn btn-success btn-xs" type="button">'
                					+'<i class="-fa fa-download"></i>&nbsp;&nbsp;<span class="bold">导出</span>'
                				+'</button>'
                	        	+'</td>'
                			+'</tr>';
                    	$("#packRecordList").append(list);
                	}
                }
			}
		});
	}

		
		/*打包记录表单验证*/
		function PackCheck() {
				$("form.form-package-body").validate({
		            rules: {
		            	productBatch: {
		                    required: true,
		                },
		            	deliveryBatch: {
		                    required: true,
		                }, 
		                deviceId: {
		                    required: true,
		                },
		                producerId:{
		                	required: true,
		                	number: true
		                },
		                teaWeight:{
		                	required: true,
		                	number: true     //输入必须是数字
		                },
		                teaNumber:{
		                	required:true,
		                	number: true     //输入必须是数字
		                }
		            },
		            submitHandler: function() {
		                //此处写请求后台的ajax
		                let data = $("form.form-package-body").serialize();
		                $.ajax({
		                	url: rootPath + "/production/record/addPackRecord.do",
		                	type:"POST",
		                	data : data,
		                	dataType : "json",
		                    success : function (response) {
		                    	layer.alert(response.message, {icon: 1, title:'提示'});
		                    }                	  
		                });
		                
		            }
		        })
	        
	    }

		
	</script>
	<script type="text/javascript">
	function showDetail(obj){
		var node = obj.parentNode.parentNode.children[3];
		var value = node.innerText;
		$.ajax({
			url : rootPath
					+ "/production/record/queryRecordByProductBatch.do",
			type : "POST",
			data : {productBatch : value},
			success : function(response) {
				var response = eval("("+response+")");
            	if(response.RESUTL === "failed"){
                	$.modal.alert(response.message);
                }else{
                	record = response.record;
					var node1 = obj.parentNode.parentNode.children[3];
					var productBatch = node.innerText;
					var head = productBatch.substr(0,1);
					
					var detail = "";
					if(head == "F"){// 杀青
						detail = "<div class='modal-header'>"
		        		+"<button type='button' class='close' data-dismiss='modal'>"
		        		+"<span aria-hidden='true'>×</span><span class='sr-only'>Close</span></button>"
		        		+"<h4 class='modal-title'>"+ record.productBatch +"批次记录详细</h4>"
		        		+"<small class='font-bold'> 记录人员id："+record.producerId +"&nbsp;&nbsp;记录时间："+ record.recordTime
		        		+"</small></div><small class='font-bold'><div class='modal-body'><table id='bootstrap-table' data-mobile-responsive='true' class='table table-hover'>"
		        		+"<thead><tr><th><div class='th-inner '>参数名</div><div class='fht-cell'></div></th><th><div class='th-inner '>参数值</div>"
		        		+"<div class='fht-cell'></div></th></tr></thead><tbody>"
		        		+"<tr data-index='0'><td>茶叶出库批次</td><td>"+ record.deliveryBatch +"</td>"
		        		+"</tr><tr data-index='1'><td>生产批次</td><td>"+ record.productBatch +"</td></tr>"
		        		+"</tr><tr data-index='2'><td>设备编号</td><td>"+ record.deviceId +"</td></tr>"
		        		+"</tr><tr data-index='3'><td>鲜叶含水量</td><td>"+ record.freshLeafWaterContent +"</td></tr>"
		        		+"</tr><tr data-index='4'><td>杀青后含水量</td><td>"+ record.weightLast +"</td></tr>"
		        		+"</tr><tr data-index='5'><td>生产员id</td><td>"+ record.producerId +"</td></tr>"
		        		+"</tr><tr data-index='6'><td>记录时间</td><td>"+ record.recordTime +"</td></tr>"
		        		+"</tbody></table></div><div class='modal-footer'>"
		        		+"<button type='button' class='btn btn-white' data-dismiss='modal'>关闭</button><button type='button' class='btn btn-primary'>修改</button>"
		        		+"</div></small></div><small class='font-bold'> </small>";
					}else if(head == "T"){ // 揉捻
						detail = "<div class='modal-header'>"
		        		+"<button type='button' class='close' data-dismiss='modal'>"
		        		+"<span aria-hidden='true'>×</span><span class='sr-only'>Close</span></button>"
		        		+"<h4 class='modal-title'>"+ record.productBatch +"批次记录详细</h4>"
		        		+"<small class='font-bold'> 记录人员id："+record.producerId +"&nbsp;&nbsp;记录时间："+ record.recordTime
		        		+"</small></div><small class='font-bold'><div class='modal-body'><table id='bootstrap-table' data-mobile-responsive='true' class='table table-hover'>"
		        		+"<thead><tr><th><div class='th-inner '>参数名</div><div class='fht-cell'></div></th><th><div class='th-inner '>参数值</div>"
		        		+"<div class='fht-cell'></div></th></tr></thead><tbody>"
		        		+"<tr data-index='0'><td>茶叶出库批次</td><td>"+ record.deliveryBatch +"</td>"
		        		+"</tr><tr data-index='1'><td>生产批次</td><td>"+ record.productBatch +"</td></tr>"
		        		+"</tr><tr data-index='2'><td>设备编号</td><td>"+ record.deviceId +"</td></tr>"
		        		+"</tr><tr data-index='3'><td>投叶量</td><td>"+ record.volume +"</td></tr>"
		        		+"</tr><tr data-index='4'><td>含水量</td><td>"+ record.waterRate +"</td></tr>"
		        		+"</tr><tr data-index='5'><td>细胞破损率</td><td>"+ record.outCellRate +"</td></tr>"
		        		+"</tr><tr data-index='6'><td>叶形</td><td>"+ record.outShape +"</td></tr>"
		        		+"</tr><tr data-index='7'><td>成条率</td><td>"+ record.outRate +"</td></tr>"
		        		+"</tr><tr data-index='8'><td>生产员id</td><td>"+ record.producerId +"</td></tr>"
		        		+"</tr><tr data-index='9'><td>记录时间</td><td>"+ record.recordTime +"</td></tr>"
		        		+"</tbody></table></div><div class='modal-footer'>"
		        		+"<button type='button' class='btn btn-white' data-dismiss='modal'>关闭</button><button type='button' class='btn btn-primary'>修改</button>"
		        		+"</div></small></div><small class='font-bold'> </small>";
						$("#recordDetail").html(detail);
					}else if(head == "D"){// 干燥
						detail = "<form class=\"form-updateDryRecored-body\"  >"
                        +"<input class='form-control' type='hidden' name='id'  value="+record.id + "  / >"
                        +"<div class='modal-header'>"
                        +"<button type='button' class='close' data-dismiss='modal'>"
                        +"<span aria-hidden='true'>×</span><span class='sr-only'>Close</span></button>"
                        +"<h4 class='modal-title'>"+ record.productBatch +"批次记录详细</h4>"
                        +"</small></div><small class='font-bold'><div class='modal-body'><table id='bootstrap-table' data-mobile-responsive='true' class='table table-hover'>"
                        +"<thead><tr><th><div class='th-inner '>参数名</div><div class='fht-cell'></div></th><th><div class='th-inner '>参数值</div>"
                        +"<div class='fht-cell'></div></th></tr></thead><tbody>"
                        +"<tr data-index='0'><td>生产批次</td><td>"
                        +"<input type='text' class='form-control' name='productBatch' value="+record.productBatch + "  / >"
                        +"</td>"
                        +"</tr><tr data-index='1'><td>购买批次</td><td>"
                        +"<input type='text' class='form-control' name='deliveryBatch'  value="+record.deliveryBatch + "  / >" +"</td></tr>"
                        +"</tr><tr data-index='2'><td>设备编号</td><td>"+"<input type='text' class='form-control' name='deviceId'  value="+record.deviceId + "  / >" +"</td></tr>"
                        +"</tr><tr data-index='3'><td>生产员编号</td><td>"+"<input type='text' class='form-control'  name='producerId' value="+record.producerId + "  / >"  +"</td></tr>"
                        +"</tr><tr data-index='5'><td>生产员姓名</td><td>"+"<input type='text' class='form-control' name='name'  value="+record.name + "  / >"  +"</td></tr>"
                        +"</tr><tr data-index='5'><td>记录时间</td><td>"+"<input type='text' class='form-control' disabled='disabled' value="+record.recordTime + "  / >"  +"</td></tr>"
                        +"</tr><tr data-index='4'><td>产出重量</td><td>"+"<input type='text' class='form-control' name='weight' value="+record.weight + "  / >"  +"</td></tr>"
                        +"</tr><tr data-index='5'><td>完成时含水量</td><td>"+"<input type='text' class='form-control' name='waterLastRate' value="+record.waterLastRate + "  / >"  +"</td></tr>"
						+"</tbody></table></div><div class='modal-footer'>"
                        +"<button type='button' class='btn btn-white' data-dismiss='modal'>关闭</button><button type='button' onclick='updateDryRecordStandardCheck()' class='btn btn-primary' data-dismiss='modal'>修改</button>"
                        +"</div></small></div><small class='font-bold'> </small>"
                        + "</form>";
					}else if(head == "P"){// 打包
						detail = "<div class='modal-header'>"
		        		+"<button type='button' class='close' data-dismiss='modal'>"
		        		+"<span aria-hidden='true'>×</span><span class='sr-only'>Close</span></button>"
		        		+"<h4 class='modal-title'>"+ record.productBatch +"批次记录详细</h4>"
		        		+"<small class='font-bold'> 记录人员id："+record.producerId +"&nbsp;&nbsp;记录时间："+ record.packTime
		        		+"</small></div><small class='font-bold'><div class='modal-body'><table id='bootstrap-table' data-mobile-responsive='true' class='table table-hover'>"
		        		+"<thead><tr><th><div class='th-inner '>参数名</div><div class='fht-cell'></div></th><th><div class='th-inner '>参数值</div>"
		        		+"<div class='fht-cell'></div></th></tr></thead><tbody>"
		        		+"<tr data-index='0'><td>茶叶出库批次</td><td>"+ record.deliveryBatch +"</td>"
		        		+"</tr><tr data-index='1'><td>生产批次</td><td>"+ record.productBatch +"</td></tr>"
		        		+"</tr><tr data-index='2'><td>设备编号</td><td>"+ record.deviceId +"</td></tr>"
		        		+"</tr><tr data-index='4'><td>生产员Id</td><td>"+ record.producerId +"</td></tr>"
		        		+"</tr><tr data-index='5'><td>打包数量</td><td>"+ record.teaNumber +"</td></tr>"
		        		+"</tr><tr data-index='4'><td>打包单位重量</td><td>"+ record.teaWeight +"</td></tr>"
		        		+"</tr><tr data-index='5'><td>记录时间</td><td>"+ record.recordTime +"</td></tr>"
		        		+"</tbody></table></div><div class='modal-footer'>"
		        		+"<button type='button' class='btn btn-white' data-dismiss='modal'>关闭</button><button type='button' class='btn btn-primary'>修改</button>"
		        		+"</div></small></div><small class='font-bold'> </small>";
					}	
					$("#recordDetail").html(detail);
		        	
                }
         		
			}
				
		});
		
	}
	</script>

</body>
</html>
